package edu.jd.software.web.backend.common.utils;

import io.swagger.v3.oas.models.Operation;
import org.springdoc.core.customizers.OperationCustomizer;
import org.springframework.stereotype.Component;
import org.springframework.web.method.HandlerMethod;

import java.util.Collections;

// 自定义过滤器
@Component
public class PublicApiFilter implements OperationCustomizer {

    @Override
    public Operation customize(Operation operation, HandlerMethod handlerMethod) {
        if (handlerMethod.getMethodAnnotation(PublicApi.class) != null) {
            operation.security(Collections.emptyList());  // 清空安全要求
        }
        return operation;
    }
}
